var DateUtil = {};

DateUtil.Format=function(op){
    var m, year, month, day;
    var formatString = "ymd";
		switch(formatString){
			case "ymd" :
				m = op.match(new RegExp("^((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})$"));
				if(m == null ) return false;
				day = m[6];
				month = m[5]*1;
				year =  (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10));
				break;
			case "dmy" :
				m = op.match(new RegExp("^(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))$"));
				if(m == null ) return false;
				day = m[1];
				month = m[3]*1;
				year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10));
				break;
			default :
				break;
		}
		if(!parseInt(month)) return false;
		month = month==0 ?12:month;
		return new Date(year, month-1, day);   
};

DateUtil.AddDayByDate = function(start,num)
    {
       if(start != '')
       {       
            var b = start.split("-");
            var month = parseInt(b[1]);
            var year =parseInt(b[0]);
            var day =parseInt(b[2]);
            var num = parseInt(num);   
            if(num>0)
            	num = num-1;
            var check4=(0==year%4);            //判断年份是否能被4整除
            var check100=(0==year%100);        //判断年份是否能被100整除
            var check400=(0==year%400);        //判断年份是否能被400整除
            if((check4 && !check100) || check400)
            {
               if(month==2)
               {
                   if(day+num > 29)
                   {
                    month =month+1;
                    day= day+num-29;
                   }   
                   else
                   {
                    day= day+num;
                   }
               }   
               
            }
            else
            {
               if(month==2)
               {
                   if(day+num > 28)
                   {
                    month =month+1;
                    day= day+num-28;
                   } 
                   else
                   {
                    day= day+num;
                   }
               }
            }
            if(month==1 ||month==3 ||month==5 ||month==7 ||month==8 ||month==10 ||month==12 )
            {
               if(day+num > 31)
               {
                month =month+1;
                if(month>12)
                {
                    month =1;
                    year++;
                }
                day= day+num-31;
               }
               else
               {
                day= day+num;
               }
            }
            if(month==4 ||month==6 ||month==9 ||month==11 )
            {
               if(day+num > 30)
               {
                month =month+1;
                day= day+num-30;
               }
               else
               {
                day= day+num;
               }
            }          
            if(month < 10)
                month = "0"+ month;
            if(day < 10)
                day = "0"+ day;
            strDate = year+"-"+month+"-"+day;
            
            return strDate;
       }
    }

function renderDate(val){
	if(val && val.length>10){
		return val.substring(0,10);
	}
	return val;
}

function renderRole(val){
	if(val==1){
		return "管理员";
	}
	return "操作员";
}

function renderAttr(val){
	switch(val){
		case(0):
			return "区域";
		case(1):
			return "银行";
		case(2):
			return "银行卡类型";
		case(3):
			return "担保方式";
	}
	
}
